<?php
/*
|--------------------------------------------------------------------------
| Blog Routes
|--------------------------------------------------------------------------
 */
Route::get('/', 'Frontend\BlogController@index');
Route::get('blog', 'Frontend\BlogController@index');
Route::get('blog/{slug}', 'Frontend\BlogController@showPost');
/*
|--------------------------------------------------------------------------
| Test Routes
|--------------------------------------------------------------------------
 */
Route::get('test', ['as'=>'pro', 'uses'=>'TestController@index']);
Route::any('index/{id?}/method/{method?}', 'TestController@index')->where('method', '[a-z]+')->name('test');
Route::match(['get', 'put', 'patch', 'delete', 'options'], 'foo', 'TestController@foo');
Route::group(['as'=>'admin::'], function(){
    Route::any('cha/{id}', 'TestController@index')->name('jj');
});
Route::get('shuchu', 'TestController@shuchu')->name('shu');
Route::get('profile/{user?}', 'TestController@profile');
Route::post('puut', 'TestController@puut');
Route::get('pattch', 'TestController@pattch');
Route::get('deet', 'TestController@deet');
Route::get('hello/{id}', function ($id) {
    echo 'hello'.'<br>';
    echo $id;
});

/*
|--------------------------------------------------------------------------
| Resource Routes
|--------------------------------------------------------------------------
 */
Route::get('photo/popular', 'PhotoController@popular');
Route::resource('photo', 'PhotoController', ['only'=>['index', 'show'], 'names'=>['index'=>'photo.xxx']]);
/*
|--------------------------------------------------------------------------
| Admin Routes
|--------------------------------------------------------------------------
 */
$router->group([
    'namespace'  => 'Backend',
    'middleware' => 'auth',
], function () {
    Route::get('admin', 'HomeController@index');
    Route::resource('admin/post', 'PostController', ['except' => 'show']);
    Route::resource('admin/sort', 'SortController', ['except' => 'show']);
    Route::get('admin/sort/delete', 'SortController@del');
    Route::get('admin/sort/fight', 'SortController@fight');
    Route::resource('admin/tag', 'TagController', ['except' => 'show']);
    Route::get('admin/upload', 'UploadController@index')->name('admin/upload');
    Route::post('admin/upload/file', 'UploadController@uploadFile');
    Route::delete('admin/upload/file', 'UploadController@deleteFile');
    Route::post('admin/upload/folder', 'UploadController@createFolder');
    Route::delete('admin/upload/folder', 'UploadController@deleteFolder');
    Route::get('admin/profile/privacy', 'ProfileController@editPrivacy')->name('admin.profile.privacy');
    Route::resource('admin/profile', 'ProfileController');
    Route::resource('admin/search', 'SearchController');
    Route::get('admin/tools', 'ToolsController@index');
    Route::post('admin/tools/reset_index', 'ToolsController@resetIndex');
    Route::post('admin/tools/cache_clear', 'ToolsController@clearCache');
    Route::post('admin/tools/download_archive', 'ToolsController@handleDownload');
    Route::post('admin/tools/enable_maintenance_mode', 'ToolsController@enableMaintenanceMode');
    Route::post('admin/tools/disable_maintenance_mode', 'ToolsController@disableMaintenanceMode');
});

/*
|--------------------------------------------------------------------------
| Logging In/Out Routes
|--------------------------------------------------------------------------
 */
$router->group([
    'namespace' => 'Auth',
    'prefix'    => 'auth',
], function () {
    Route::get('login', 'AuthController@getLogin');
    Route::post('login', 'AuthController@postLogin');
    Route::get('logout', 'AuthController@getLogout');
    Route::post('password', 'PasswordController@updatePassword');
});

/*
|--------------------------------------------------------------------------
| Send emails
|--------------------------------------------------------------------------
 */
Route::get('mail/send', 'MailController@send');